<?php
/**
 * Lev.levme.com [ 专业开发各种Discuz!插件 ]
 *
 * Copyright (c) 2013-2014 http://www.levme.com All rights reserved.
 *
 * Author: Mr.Lee <675049572@qq.com>
 *
 * Date: 2013-02-17 16:22:17 Mr.Lee $
 */

if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')){
	exit('Access Denied');
}

require_once 'lev_enter.php';

$fna    = str_replace('.inc.php', '', basename(__FILE__));
$theurl = 'admin.php?action=plugins&operation=config&do='.$pluginid.'&identifier='.$PLNAME.'&pmod='.$fna.'&fh='.FORMHASH;

if (FORMHASH ==$_GET['fh']) {
	if ($_GET['setstatus']) {
		ob_clean();
		$opid = intval($_GET['opid']);
		$rs = DB::fetch_first("SELECT * FROM ".DB::table('lev_bank_log')." WHERE id='$opid'");
		if ($rs['status']) { $status = 0; }else { $status = 1; }
		DB::update('lev_bank_log', array('status'=>$status), array('id'=>$opid));
		echo $status;exit();
	}elseif ($_GET['setoption']) {
		ob_clean();
		$opid = intval($_GET['opid']);
		$name = trim($_GET['name']);
		$value= trim(lev_class::levdiconv($_GET['value']));
		DB::update('lev_bank_log', array($name=>$value), array('id'=>$opid));
		exit('1');
	}elseif ($_GET['deldata']) {
		ob_clean();
		$opid = intval($_GET['opid']);
		DB::query("DELETE FROM ".DB::table('lev_bank_log')." WHERE `id`='$opid'");
		exit('1');
	}elseif ($_GET['dosuc']) {
		ob_clean();
		$opid = intval($_GET['opid']);
		$status = intval($_GET['dosuc']);
		$rs = DB::fetch_first("SELECT * FROM ".DB::table("lev_bank_log")." WHERE id='$opid'");
		if ($rs) {
			$contents = lev_base::levdiconv(strip_tags($_GET['conts']), 'utf-8', CHARSET);
			$updatas = array('contents'=>$contents);
			if (!$rs['status']) $updatas['status'] = $status;
			DB::update('lev_bank_log', $updatas, array('id'=>$opid));
			if ($status ==2 && !$rs['status']) {
				$score = ceil(($rs['money'] + $rs['per']) * lev_class::duihuan());
				$sc = lev_base::acscore($score, '', 0, $rs['uid']);
				if (!$sc) exit('-1');
			}
			exit('1');
		}
		exit('-2');
	}
}

$sts = array(
	0  => '<span style="color:red">'.$lev_lang['st0'].'</span>', 
	2  => '<span style="color:#999">'.$lev_lang['st2'].'</span>', 
	99 => '<span style="color:green">'.$lev_lang['st99'].'</span>');
$_theurl = $theurl;
if (is_numeric($_GET['sltss'])) {
	$sltss = intval($_GET['sltss']);
	$theurl .='&sltss='.$sltss;
}
$_sq = is_numeric($sltss) ? "status='$sltss'" : "1";
$ads = lev_class::levpages('lev_bank_log', $_sq." ORDER BY addtime DESC", 20, 0, $theurl);
foreach ($ads['lists'] as $r) {
	$bank = unserialize($r['bankinfo']);
	$addtime = dgmdate($r['addtime'], 'u');
	$status  = $sts[$r['status']];
	$adlists.= <<<EOF
	<tr><td>{$r['id']}</td>
	<td title="{$r['contents']}" style="width:180px;">{$r['codenum']}
	<p style="width:160px;height:18px;overflow:hidden;">{$r['contents']}</p></td>
	<td><a href="home.php?mod=space&uid={$r['uid']}" target="_blank">{$r['bbsname']}</a></td>
	<td>{$bank['rname']}</td>
	<td>{$bank['bankname']}<br>{$bank['cardnum']}</td>
	<td><font color=#f60>{$r['money']}</font>&yen;</td>
	<td>-{$r['per']}&yen;</td>
	<td>{$status}</td>
	<td>{$addtime}</td>
	<td>
	<a href="javascript:;" onclick="setsts({$r['id']}, '{$r['codenum']}')" title="{$r['contents']}">{$lev_lang['cul']}</a> | 
	<a href="javascript:;" onclick="deldata(this, {$r['id']})">{$lev_lang['del']}</a>
	</td>
	</tr>
EOF;
}

$formhash = FORMHASH;
$html = <<<EOF

<link rel="stylesheet" href="{$PLSTATIC}css/css.css" type="text/css">
<script type="text/javascript" src="{$PLSTATIC}dialog417/dialog.js?skin=default"></script>
<script type="text/javascript" src="{$PLSTATIC}dialog417/plugins/iframeTools.js"></script>
<script type="text/javascript" src="{$PLSTATIC}jquery.min.js"></script>
<script type="text/javascript" src="static/js/common.js?WT2"></script>
<script type="text/javascript" src="static/js/calendar.js"></script>

<script type="text/javascript">var $$ = jQuery.noConflict();</script>
<style>
#levad .none {display:none;}
#levad .rfm {
    border-bottom: 1px dotted #CDCDCD;
}
#levad .rfm .adlists td {
    border-bottom: 1px dotted #CDCDCD;
}
#levad .rfm th {
    padding-right: 10px;
    text-align: right;
    width: 10em;
}
#levad .rfm th, .rfm td {
    line-height: 24px;
    padding:4px;
    vertical-align: middle;
}
#levad input, #levad select, #levad textarea {width:220px;}
#levad .sa a {
	display: inline-block;
	vertical-align: middle;
	position: relative;
	border: 2px solid #FFF;
	text-align:center;
}
#levad .sa a:hover {border: 2px solid #006A92;}
#levad .sa a.simg {border: 2px solid #006A92;}
#levad .sa a.simg em {
	display: block;
	width: 15px;
	height: 15px;
	position: absolute;
	right: -1px;
	bottom: -1px;
	overflow: hidden;
	background: url({$PLSTATIC}img/temper_120718.gif) no-repeat;
}
#levad .userg input {width:auto;margin:0 0 0 5px;vertical-align: middle;}


</style>
<div id="levad">

<div class="rfm">
<table>
<tr><th>{$lev_lang['cul1']}{$lev_lang['mh']}</th><td>
<a href="{$_theurl}">{$lev_lang['all']}</a> | 
<a href="{$theurl}&sltss=0"><span style="color:red">{$lev_lang['st0']}</span></a> | 
<a href="{$theurl}&sltss=2"><span style="color:#999">{$lev_lang['st2']}</span></a> | 
<a href="{$theurl}&sltss=99"><span style="color:green">{$lev_lang['st99']}</span></a>
</td>
<td> &raquo; <a target="_blank" href="home.php?mod=spacecp&ac=plugin&op=credit&id=levbank:levbank">{$lev_lang['cul2']}</a></td>
</tr>
</table>
</div>
<div class="rfm">
<table class="adlists" width="100%">
<tr>
{$lev_lang['cul3']}
</tr>
{$adlists}
</table>
</div>

<div class="rfm">
<table width="100%">
<tr>
<th></th>
<td style="text-align:right">{$ads['pages']}</td>
</tr>
</table>
</div>

<script>

function setsts(id, codenum) {
	var contents = '<table><tr><td>{$lev_lang['cul4']}'+ codenum +'{$lev_lang['cul5']}</td></tr>'+
					'<tr><td><textarea name="dinfos" id="dinfos" style="width:320px;height:100px;"></textarea></td></tr></table>';
	art.dialog({title:'{$lev_lang['cul6']}', id:'setss', content:contents, 
	button:[{
		name:'{$lev_lang['cul7']}',
		callback:function(){
			dosucc(99, id);
		},
		focus:true
	},{
		name:'{$lev_lang['cul8']}',
		callback:function(){
			if (confirm('['+ codenum +']{$lev_lang['cul9']}')) dosucc(2, id);
		}
	}], cancel:true});
}
function dosucc(_type, id){
	var conts = $$("#dinfos").val();
	$$.get('$theurl&dosuc='+ _type, {opid:id, conts:conts}, function(data){
		if (parseInt(data) =="1") {
			//art.dialog({id:'setss'}).close();
			art.dialog.tips("{$lev_lang['succeed']}");
		}else {
			art.dialog.tips("{$lev_lang['error']}"+ data, 10);
		}
	});
}

function setstatus(obj, id, name) {
	//var name = name ? name : '';
	$$.get('{$theurl}&setstatus=1', {opid:id, name:name, t:Math.random()}, function(data){
		switch(parseInt(data)) {
			case 0 :
				$$(obj).html('{$sts[0]}');
				break;
			case 1 :
				$$(obj).html('{$sts[1]}');
				break;
		}
		art.dialog.tips('{$lev_lang['succeed']}');
	});
}

function setoption(obj, id, name, value) {
	$$.get('{$theurl}&setoption=1', {opid:id, name:name, value:value, t:Math.random()}, function(data){
		art.dialog.tips('{$lev_lang['succeed']}');
	});
}

function deldata(obj, id) {
	if (confirm('{$lev_lang['confirm']}'+ id)) {
		$$.get('{$theurl}&deldata=1', {opid:id, t:Math.random()}, function(data) {
			art.dialog.tips('{$lev_lang['succeed']}');
			$$(obj).parent().parent().fadeOut('slow');
		});
	}
}

function toMao(val){
	var myY = $$("#"+val).offset().top
	$$("html,body").stop().animate({ scrollTop:myY},500);
}
</script>

</div>
EOF;
echo $html;
?>











